// src/stores/user.ts
import { defineStore } from 'pinia';

export const useUserStore = defineStore('user', {
  state: () => ({
    user: null as { name: string; email: string } | null,
  }),
  getters: {
    getUser: (state) => state.user,
    isAuthenticated: (state) => !!state.user,
  },
  actions: {
    setUser(newUser: { name: string; email: string }) {
      this.user = newUser;
    },
    logout() {
      this.user = null;
    },
  },
});